#include <iostream>
#include <string>  
#include "../include/car.h"

using namespace std;

SmartCar::SmartCar(std::string file):chassis("aa"){}
    // 构造函数，只接受小车编号和底盘编号作为输入  
SmartCar::SmartCar(const std::string& carId, const std::string& chassisId)   
    : carId(carId), chassis(chassisId) {}  



void SmartCar::writeToFile(std::ofstream &file) {
    if (file.is_open()) {
        // 存入学生信息
        file << "学号:" << student.getId() << endl;
        file << "姓名:" << student.getName() << endl;
        file << "carId:" << carId << endl;
        chassis.writeToFile(file);
        agxKit.writeToFile(file);
        camera.writeToFile(file);
        lidar.writeToFile(file);
        gyroscope.writeToFile(file);
        display.writeToFile(file);
        battery.writeToFile(file);
    }
}

void SmartCar::print() const{

    student.print();

    cout << "carId:" << carId << endl;
    chassis.print();
    agxKit.print();
    camera.print();
    lidar.print();
    gyroscope.print();
    display.print();
    battery.print();
}

bool SmartCar::setStudent(const Student &st){
    student = st;
    return true;
}

Student SmartCar::getStudent(){return student;}

string SmartCar::getCarId() const{
    return carId;
}

string SmartCar::getChassisId() const{
    return chassis.getId();
}

